package DynamicProgramming;

import java.io.PrintWriter;
import java.util.Scanner;

class Solver1073
{	int n;
	int[] Rs;
	
	public void Input()
	{	Scanner in=new Scanner(System.in);
		n=in.nextInt();
		Rs=new int[n+1];
	}
	public void Solve()
	{	int cap,min;
		Rs[0]=0;
		for (int i=1;i<=n;i++)
		{	cap=(int)Math.sqrt(i);
			min=i;
			for (int j=1;j<=cap;j++)
			{	int tmp=Rs[i-j*j]+1;
				if (tmp<min) min=tmp;
			}
			Rs[i]=min;
		}
	}
	public void Output()
	{	PrintWriter out=new PrintWriter(System.out);
		out.println(Rs[n]);
		out.flush();
	}
	public void main()
	{	Input();
		Solve();
		Output();
	}
}
public class P1073
{	public static void main(String[] args)
	{	Solver1073 solver=new Solver1073();
		solver.main();
	}
}
